-- @owner: @zou_jialiang050
-- @date: 2023/2/20
-- @testpoint: create function 使用原有语句创建触发器函数

--step1:建表;expect:成功
drop table if exists t_create_function_0035;
drop table if exists t_create_function_0035_1;
create table t_create_function_0035(id1 int, id2 int, id3 int);
create table t_create_function_0035_1(id1 int, id2 int, id3 int);

--step2:create function 使用原有语句创建触发器函数;expect:成功
create or replace function f_create_function_0035() returns trigger as
$$
declare
begin
insert into t_create_function_0035_1 values(new.id1, new.id2, new.id3);
return new;
end
$$ language plpgsql;
/
create trigger tri_create_function_0035
before insert on t_create_function_0035
for each row
execute procedure f_create_function_0035();
/
insert into t_create_function_0035 values(100,200,300);
select * from t_create_function_0035;
select * from t_create_function_0035_1;

--step3:清理环境;expect:成功
drop trigger if exists tri_create_function_0035;
drop function if exists f_create_function_0035;
drop table if exists t_create_function_0035;
drop table if exists t_create_function_0035_1;